//
//  AIGirlDeleteView.swift
//  AIGirl
//
//  Created by Rae on 2023/12/28.
//

import UIKit
import SwiftEntryKit

class AIGirlDeleteView: UIView, AnimationProtocol, AnimationDelegate {

    func animationContainerViewSize() -> CGSize {
        CGSize(width: .screenWidth - 30.0, height: 250.0)
    }
    
    func animationContainerViewStyle() -> AnimationViewStyle {
        .center
    }
    
    func animationContainerScreenInteraction() -> EKAttributes.UserInteraction {
        .init()
    }
    
    private let titleLabel = c_make_ex(UILabel.self)
        .font(17.font_bold).color(.white)
        .alignment(.center).text("Delete account").end()
    private let desLabel = c_make_ex(UILabel.self)
        .font(16.font_medium).color("#E2D2FC".toColor.alpha(0.84))
        .line(0).alignment(.center)
        .text("After deleting your account, your diamonds and memberships will be deleted. It is not recoverable. Please confirm whether to delete it.").end()
    private let delButton = c_make_ex(UIButton.self)
        .font(21.font_bold).color("#E2D2FC").bgColor("#E2D2FC".toColor.alpha(0.2))
        .alignment(.center).text("Delete").corner(20).end()
    private let cancelButton = c_make_ex(UIButton.self)
        .font(21.font_bold).color(.white).bgImage("AIGirl_Button_bg")
        .alignment(.center).text("Cancel").corner(20).end()
    var deleteClosure: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = "#1B1325".toColor
        self.layer.cornerRadius = 30
        self.layer.masksToBounds = true
        
        subviews{
            titleLabel
            desLabel
            delButton
            cancelButton
        }
        
        titleLabel.top(22).centerHorizontally()
        desLabel.leading(23).trailing(23).top(58)
        delButton.leading(20).width(145).height(50).bottom(20)
        cancelButton.trailing(20).width(145).height(50).bottom(20)
        
        cancelButton.addTarget(self, action: #selector(clickCancelButton), for: .touchUpInside)
        delButton.addTarget(self, action: #selector(clickDeleteButton), for: .touchUpInside)
    }
    
    @objc private func clickCancelButton(){
        animation.animation(dismiss: self)
    }
    
    @objc private func clickDeleteButton(){
        animation.animation(dismiss: self){
            self.deleteClosure?()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

class AIGirlClearView: UIView, AnimationProtocol, AnimationDelegate {

    func animationContainerViewSize() -> CGSize {
        CGSize(width: .screenWidth - 30.0, height: 205.0)
    }
    
    func animationContainerViewStyle() -> AnimationViewStyle {
        .center
    }
    
    func animationContainerScreenInteraction() -> EKAttributes.UserInteraction {
        .init()
    }
    
    private let titleLabel = c_make_ex(UILabel.self)
        .font(17.font_bold).color(.white)
        .alignment(.center).text("clear message").end()
    private let desLabel = c_make_ex(UILabel.self)
        .font(16.font_medium).color("#E2D2FC".toColor.alpha(0.84))
        .line(0).alignment(.center)
        .text("After clearing the message, the message record cannot be restored.").end()
    private let delButton = c_make_ex(UIButton.self)
        .font(21.font_bold).color("#E2D2FC").bgColor("#E2D2FC".toColor.alpha(0.2))
        .alignment(.center).text("Clear").corner(20).end()
    private let cancelButton = c_make_ex(UIButton.self)
        .font(21.font_bold).color(.white).bgImage("AIGirl_Button_bg")
        .alignment(.center).text("Cancel").corner(20).end()
    var clearClosure: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = "#1B1325".toColor
        self.layer.cornerRadius = 30
        self.layer.masksToBounds = true
        
        subviews{
            titleLabel
            desLabel
            delButton
            cancelButton
        }
        
        titleLabel.top(22).centerHorizontally()
        desLabel.leading(23).trailing(23).top(58)
        delButton.leading(20).width(145).height(50).bottom(25)
        cancelButton.trailing(20).width(145).height(50).bottom(25)
        
        cancelButton.addTarget(self, action: #selector(clickCancelButton), for: .touchUpInside)
        delButton.addTarget(self, action: #selector(clickDeleteButton), for: .touchUpInside)
    }
    
    @objc private func clickCancelButton(){
        animation.animation(dismiss: self)
    }
    
    @objc private func clickDeleteButton(){
        animation.animation(dismiss: self){
            self.clearClosure?()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
